<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div>
    dakai12345
</div>
</body>
<script>
    // 双斜杠是字面量形式
    let con = prompt("请输入要检测的内容，支持正则")
    let reg = new RegExp(con,'g')
    let div = document.querySelector('div')
    div.innerHTML = div.innerHTML.replace(reg,search=>{
        return `<span style="color: red">${search}</span>`
    })
</script>
</html>
